package com.ahdms.es.bean;

/**
 * 证书信息
 *
 * @author qinxiang
 * @date 2021-04-16 15:22
 */
public class CertInfo {
    /**
     * 版本号
     */
    private String version;
    /**
     * 签名算法
     */
    private String algorithm;

    /**
     * 证书序列号
     */
    private String serialNum;

    /**
     * 使用者
     */
    private String subjectDN;

    /**
     * 颁发者
     */
    private String issuerDN;

    /**
     * 有效期开始时间
     */
    private String notBefore;

    /**
     * 有效期结束时间
     */
    private String notAfter;

    public CertInfo() {
    }

    public CertInfo(String version, String algorithm, String serialNum, String subjectDN, String issuerDN, String notBefore, String notAfter) {
        this.version = version;
        this.algorithm = algorithm;
        this.serialNum = serialNum;
        this.subjectDN = subjectDN;
        this.issuerDN = issuerDN;
        this.notBefore = notBefore;
        this.notAfter = notAfter;
    }

    public static CertInfo.CertInfoBuilder bulider(){
        return new CertInfo.CertInfoBuilder();
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getAlgorithm() {
        return algorithm;
    }

    public void setAlgorithm(String algorithm) {
        this.algorithm = algorithm;
    }

    public String getSerialNum() {
        return serialNum;
    }

    public void setSerialNum(String serialNum) {
        this.serialNum = serialNum;
    }

    public String getSubjectDN() {
        return subjectDN;
    }

    public void setSubjectDN(String subjectDN) {
        this.subjectDN = subjectDN;
    }

    public String getIssuerDN() {
        return issuerDN;
    }

    public void setIssuerDN(String issuerDN) {
        this.issuerDN = issuerDN;
    }

    public String getNotBefore() {
        return notBefore;
    }

    public void setNotBefore(String notBefore) {
        this.notBefore = notBefore;
    }

    public String getNotAfter() {
        return notAfter;
    }

    public void setNotAfter(String notAfter) {
        this.notAfter = notAfter;
    }

    @Override
    public String toString() {
        return "{" +
                "version='" + version + '\'' +
                ", algorithm='" + algorithm + '\'' +
                ", serialNum='" + serialNum + '\'' +
                ", subjectDN='" + subjectDN + '\'' +
                ", issuerDN='" + issuerDN + '\'' +
                ", notBefore='" + notBefore + '\'' +
                ", notAfter='" + notAfter + '\'' +
                '}';
    }

    public static class CertInfoBuilder{

        private String version;

        private String algorithm;

        private String serialNum;

        private String subjectDN;

        private String issuerDN;

        private String notBefore;

        private String notAfter;

        CertInfoBuilder(){

        }

        public CertInfo.CertInfoBuilder version(final String version){
            this.version = version;
            return this;
        }

        public CertInfo.CertInfoBuilder algorithm(final String algorithm){
            this.algorithm = algorithm;
            return this;
        }

        public CertInfo.CertInfoBuilder serialNum(final String serialNum){
            this.serialNum = serialNum;
            return this;
        }

        public CertInfo.CertInfoBuilder subjectDN(final String subjectDN){
            this.subjectDN = subjectDN;
            return this;
        }

        public CertInfo.CertInfoBuilder issuerDN(final String issuerDN){
            this.issuerDN = issuerDN;
            return this;
        }

        public CertInfo.CertInfoBuilder notBefore(final String notBefore){
            this.notBefore = notBefore;
            return this;
        }

        public CertInfo.CertInfoBuilder notAfter(final String notAfter){
            this.notAfter = notAfter;
            return this;
        }

        public CertInfo build(){
            return new CertInfo(this.version,this.algorithm,this.algorithm,this.subjectDN,this.issuerDN,this.notBefore,this.notAfter);
        }

    }

}
